import Mock from "mockjs";
import floors from './floors.json'

/*
  1. 下载mockjs
    npm i mockjs
  2. 创建文件 mock/index.js
  3. 拦截ajax请求，返回模拟数据
    http://mockjs.com/examples.html
  4. 文件必须要main.js引入生效
  5. 发送请求，请求mock数据
    定义requestMock: /api --> /mock
    使用requestMock发送请求
  6. vuex流程
*/

// 拦截ajax请求
// 拦截请求地址为 /mock/banners 并且 请求方式 get
// 返回后面这个数据
Mock.mock("/mock/banners", "get", {
  code: 200,
  "data|4-8": [
    {
      "id|+1": 1,
      imgUrl: Mock.Random.image(
        "730x450",
        Mock.Random.color(),
        Mock.Random.color(),
        "png",
        "@ctitle"
      ),
      imgName: "@cname",
    },
  ],
});

Mock.mock("/mock/floors", "get", {
  code: 200,
  data:floors
});
